require('dotenv').config()

module.exports = {
  appId: process.env.XHP_APP_ID || 'your_app_id',
  apiSecret: process.env.XHP_API_SECRET || 'your_api_secret',
  baseUrl: process.env.BASE_URL || 'http://localhost:5000',
  frontendUrl: process.env.FRONTEND_URL || 'http://localhost:3000',
  // 首充优惠配置
  firstRechargeBonus: {
    enabled: true,
    bonusRate: 0.2, // 首充赠送20%
    maxBonus: 50 // 最多赠送50虚拟币
  },
  
  // 虚拟币充值套餐
  getVirtualCoinPackages: () => [
    {
      id: 'p1',
      amount: 9.9,
      coins: 10,
      name: '10虚拟币',
      description: '9.9元购买10虚拟币'
    },
    {
      id: 'p2',
      amount: 19.9,
      coins: 30,
      name: '30虚拟币',
      description: '19.9元购买30虚拟币'
    },
    {
      id: 'p3',
      amount: 39.9,
      coins: 70,
      name: '70虚拟币',
      description: '39.9元购买70虚拟币'
    }
  ],
  
  // 检查是否首次充值
  hasRechargedBefore: async (userId) => {
    const { Payment } = require('../models')
    const count = await Payment.count({
      where: {
        userId,
        status: 'paid'
      }
    })
    return count > 0
  }
}